﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Threading;
using System.Web.Security;

namespace MovieWebApp.Pages
{
    public partial class Check_Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void InitializeCulture()
        {
            if ((string)Session["Language"] != null)
            {
                string selectedLanguage = (string)Session["Language"];
                UICulture = selectedLanguage;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage);
            }
            base.InitializeCulture();
        }

        protected void btnForgot_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Pages/Question_Check.aspx");
        }

        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            NewUser.Visible = true;
            //Response.Redirect("~/Pages/Create_Account.aspx");
        }

        protected void loginSuccess(object sender, EventArgs e)
        {
            Response.Redirect("~/Pages/Member.aspx");
        }

        protected void logIn_Authenticate(object sender, AuthenticateEventArgs e)
        {
            if (Membership.ValidateUser(logIn.UserName, logIn.Password))
            {
                FormsAuthentication.RedirectFromLoginPage(logIn.UserName, false);
            }
        }

        protected void logIn_Authenticate1(object sender, AuthenticateEventArgs e)
        {
            if (Membership.ValidateUser(logIn.UserName, logIn.Password))
            {
                FormsAuthentication.RedirectFromLoginPage(logIn.UserName, false);
                if (Context.User.Identity.IsAuthenticated)
                {
                    Session["User"] = logIn.UserName;
                }
                else
                {
                    Session["User"] = "Guest";
                }
            }
            

        }

        

    }
}
